package com.jd.controller;

import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jd.entity.MessageEntity;
import com.jd.service.MessageService;

@Controller
@RequestMapping("/messageController")
public class MessageController {

	@Autowired
	private MessageService messageService;
	
	@RequestMapping("/message")
	@ResponseBody
	public ArrayList<MessageEntity> message(HttpServletRequest request){
		String userId =(String)request.getSession().getAttribute("userId");
		String fn =request.getParameter("fn");
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("fn", fn);
		hashMap.put("userId", userId);
		ArrayList<MessageEntity> messageList=messageService.getMessage(hashMap);
		return messageList;
		
	}
}
